package com.xiaolin.sports.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.qiniu.util.Auth;
import com.xiaolin.sports.common.Configuration;
import com.xiaolin.sports.common.QiniuConst;


@RequestMapping("qiniu")
@Controller
public class QiniuController extends BaseController {

	@RequestMapping("uptoken")
	void uptoken(HttpServletResponse response) throws IOException {
		String uptoken = Auth.create(QiniuConst.ACCESSKEY, QiniuConst.SECRETKEY)
				.uploadToken(Configuration.getInstance().getQiniuBucket());
		response.getWriter().println("{\"uptoken\": \"" + uptoken +"\"}");
	}
}
